package com.ruoyi.social.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.social.domain.SocialProductTrend;
import com.ruoyi.social.service.ISocialProductTrendService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 商品销量Controller
 * 
 * @author ruoyi
 * @date 2025-09-30
 */
@RestController
@RequestMapping("/social/SocialProductTrend")
public class SocialProductTrendController extends BaseController
{
    @Autowired
    private ISocialProductTrendService socialProductTrendService;

    /**
     * 查询商品销量列表
     */
    @PreAuthorize("@ss.hasPermi('social:SocialProductTrend:list')")
    @GetMapping("/list")
    public TableDataInfo list(SocialProductTrend socialProductTrend)
    {
        startPage();
        List<SocialProductTrend> list = socialProductTrendService.selectSocialProductTrendList(socialProductTrend);
        return getDataTable(list);
    }

    /**
     * 导出商品销量列表
     */
    @PreAuthorize("@ss.hasPermi('social:SocialProductTrend:export')")
    @Log(title = "商品销量", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SocialProductTrend socialProductTrend)
    {
        List<SocialProductTrend> list = socialProductTrendService.selectSocialProductTrendList(socialProductTrend);
        ExcelUtil<SocialProductTrend> util = new ExcelUtil<SocialProductTrend>(SocialProductTrend.class);
        util.exportExcel(response, list, "商品销量数据");
    }

    /**
     * 获取商品销量详细信息
     */
    @PreAuthorize("@ss.hasPermi('social:SocialProductTrend:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(socialProductTrendService.selectSocialProductTrendById(id));
    }

    /**
     * 新增商品销量
     */
    @PreAuthorize("@ss.hasPermi('social:SocialProductTrend:add')")
    @Log(title = "商品销量", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SocialProductTrend socialProductTrend)
    {
        return toAjax(socialProductTrendService.insertSocialProductTrend(socialProductTrend));
    }

    /**
     * 修改商品销量
     */
    @PreAuthorize("@ss.hasPermi('social:SocialProductTrend:edit')")
    @Log(title = "商品销量", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SocialProductTrend socialProductTrend)
    {
        return toAjax(socialProductTrendService.updateSocialProductTrend(socialProductTrend));
    }

    /**
     * 删除商品销量
     */
    @PreAuthorize("@ss.hasPermi('social:SocialProductTrend:remove')")
    @Log(title = "商品销量", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(socialProductTrendService.deleteSocialProductTrendByIds(ids));
    }
}
